//
//  HomeGoodItemCCell.m
//  com.modada.new
//
//  Created by ferver7 on 2019/3/31.
//  Copyright © 2019 ferver7. All rights reserved.
//

#import "HomeGoodItemCCell.h"

@implementation HomeGoodItemCCell
-(void)setGoodItem:(AppBaseGoodItem *)goodItem
{
    _goodItem = goodItem;
    self.nameLabel.text = goodItem.name;
    [self.iconImage sd_setImageWithURL:[NSURL URLWithString:goodItem.thumbnail] placeholderImage:mImageByName(@"")];
    if (goodItem.lowerPrice) {
        self.priceLabel.text = [NSString stringWithFormat:@"¥%@起",goodItem.lowerPrice];
    }else{
        self.priceLabel.text = [NSString stringWithFormat:@"¥%@起",@"0"];
    }
    self.sellerLabel.text = [NSString stringWithFormat:@"已售%@",goodItem.salesVolume];
    self.qiPiLabel.text = [NSString stringWithFormat:@"%@%@起批",goodItem.batchNum,goodItem.unit];
    self.shengyuLabel.text = [NSString stringWithFormat:@"剩余%ld%@",goodItem.totalStock.integerValue,goodItem.unit ];
    if ([goodItem.type isEqualToString:@"1"]) {
        self.stateLabel.text = @"专享";
    }else{
        self.stateLabel.text = @"商家";
    }
}
- (IBAction)addCartAction:(id)sender {
    
    if ([[AppUserBaseModel sharedUserData].phone isEqualToString:@"13975856648"]) {//游客模式的判断
        [[NSNotificationCenter defaultCenter] postNotificationName:@"appUserOutLogin" object:nil];
        return;
    }
    
    if (self.addCartBlock) {
        self.addCartBlock();
    }
}
@end
